﻿using Wolfpack.Core.Configuration;
using Wolfpack.Core.Interfaces.Entities;
using Wolfpack.Core;
using Wolfpack.Core.Notification.Filters.Request;

namespace Wolfpack.Contrib.Checks.NServiceBusPerformanceCounters
{
    public class NServiceBusCriticalConfigurationDiscovery : HealthCheckDiscoveryBase<NServiceBusCriticalTimeCounterCheckConfig, NServiceBusCriticalTimeCounterCheck>
    {
        protected override NServiceBusCriticalTimeCounterCheckConfig GetConfiguration()
        {
            return new NServiceBusCriticalTimeCounterCheckConfig
                       {
                           Enabled = true,
                           FriendlyId = "CHANGEME!",
                           InstanceName = "TODO: Set Queue Name",
                           MachineName = "leave blank for localhost or remote machine name",
                           NotificationMode = StateChangeNagFailNotificationFilter.FilterName,
                           NotificationThreshold = 300000
                       };
        }

        protected override void Configure(ConfigurationEntry entry)
        {
            entry.Name = "NSB-CriticalTime-Monitor";
            entry.Description = "Reports the NServiceBus Critical Time counter for a specific queue. The Critical Time counter monitors the age of the oldest message in the queue. This takes into account the whole chain from the message being sent on the client machine until successfully processed by the server. You should define a SLA for each of your endpoints and use the CriticalTime counter to make sure that you're adhering to it.";
            entry.Tags.AddIfMissing("NServiceBus");
        }
    }
}